package org.gsc.tst;

import org.gsc.src.Constants;
import org.gsc.src.CppCheckException;
import org.gsc.src.CppChecker;
import org.gsc.src.Problems;
import org.junit.Test;
import static org.junit.Assert.*;

public class functionalTestOne {
	@Test
	public void shouldHandleException(){
		CppChecker cppChecker=new CppChecker();
		assertNotNull(cppChecker);
		
		String filePath="nofile.cpp";
		Exception cppCheckException=null;
		
		try {
			cppChecker.check(filePath);
		} catch (Exception e) {
			cppCheckException=e;
		}
		
		assertTrue(cppCheckException.getClass()==CppCheckException.class);
		assertEquals(Constants.FILE_DOES_NOT_EXIST, cppCheckException.getMessage());
	}
	@Test
	public void shouldHandleFile(){
		CppChecker cppChecker=new CppChecker();
		String filePath="org/gsc/tst/cppcode/file.cpp";
		try {
			cppChecker.check(filePath);
		} catch (Exception e) {
			assertTrue(false);
		}
	}
	@Test
	public void shouldReportNoError(){
		CppChecker cppChecker=new CppChecker();
		String filePath="org/gsc/tst/cppcode/noerrors.cpp";
		try {
			Problems problems = cppChecker.check(filePath);
			assertEquals(0, problems.size());
		} catch (Exception e) {
			assertTrue(false);
		}
	}
}
